package edu.neusoft.springhtmldemo.mapper;

import edu.neusoft.springhtmldemo.domain.BroadcastManagement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BroadcastManagementMapper {
    @Select("select * from broadcastmanagemententity")
    List<BroadcastManagement> selectAll();

    @Select("select * from broadcastmanagemententity\n" +
            "where broadcastID like '%' #{broadcastID} '%'\n" +
            "and broadcastName like '%' #{broadcastName} '%'\n" +
            "and broadcastIP like '%' #{broadcastIP} '%'\n" +
            "and broadcastLocation like '%' #{broadcastLocation} '%'")
    List<BroadcastManagement> selectBroadcastManagement(BroadcastManagement management);

    @Select("update broadcastmanagemententity \n" +
            "set broadcastName=#{broadcastName},\n" +
            "broadcastIP=#{broadcastIP},\n" +
            "broadcastLocation=#{broadcastLocation} \n" +
            "where broadcastID=#{broadcastID}")
    void updateBroadcastManagement(BroadcastManagement management);

    @Select("INSERT into broadcastmanagemententity(broadcastName,broadcastIP,broadcastLocation)\n" +
            "value(#{broadcastName},#{broadcastIP},#{broadcastLocation})")
    void addBroadcastManagement(BroadcastManagement management);

    @Select("delete from broadcastmanagemententity where broadcastID in (#{broadcastID})")
    void delBroadcastManagement(Integer broadcastID);

    @Select("select broadcastIP from broadcastmanagemententity")
    List<String> broadcastIPValues();

    @Select("SELECT broadcastName from broadcastmanagemententity where broadcastIP=#{broadcastIP}")
    String broadcastNameValue(String broadcastIP);
}
